package lab02.Test13;

/**
 * Created by Administrator on 2017/10/20.
 */
public class Gymnastics extends ComputerAverage {
    double sum;
    double max;
    double min;

    //去掉一个最低分，去掉一个最高分，然后求平均分
    @Override
    double average(double[] scores) {
        for (int i = 0; i < scores.length; i++) {
            min = min < scores[i] ? min : scores[i];
            max = max > scores[i] ? max : scores[i];
            sum = sum + scores[i];
        }
        return (sum - max - min) / (scores.length - 2);
    }
    Gymnastics(){
        System.out.println("去掉一个最高分，去掉一个最低分求平均：");
    }
}
